import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ContainerService } from 'src/app/core/service/container.service';

@Component({
  selector: 'app-container-detail',
  templateUrl: './container-detail.component.html',
  styleUrls: ['./container-detail.component.scss'],
})

export class ContainerDetailComponent implements OnInit {
  containerId: string;
  dataSet: any;
  constructor(
    private routeInfo: ActivatedRoute,
    private containerService: ContainerService
  ) { }

  ngOnInit() {
    this.containerId = this.routeInfo.snapshot.queryParams['containerId'];
    this.getContainerDetailPage();
  }

  /**
   * @param reset 获取数据
   */
  getContainerDetailPage(reset: boolean = false): void {
    console.log('进入', this.containerId);
    if (this.containerId.length < 33 && this.containerId.length > 0) {
      this.containerService.getContainerDetailPage(this.containerId).subscribe(
        (containerDetailPage) => {
          console.log(containerDetailPage, '<--- containerDetailPage');
          this.dataSet = containerDetailPage;
          console.log(this.dataSet.servers);
          /* if (this.dataSet.servers === null || this.dataSet.servers !== undefined || this.dataSet.servers !== '') {
            this.dataSet.servers.push(
              { serverId: '', serverName: '暂无记录' }
            );
          } */
        }
      );
    }
  }
}
